package hashmap;

import java.util.HashMap;
import java.util.Iterator;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/4/27 8:45
 * @description:
 */
public class Hashmap2 {

  public static void main(String[] args) {
  //  创建hashmap对象
    HashMap<String,Student>stu = new HashMap<String, Student>();
   Student aa=new Student("miss",12);
    Student ab=new Student("mdesyrt",16);
    Student ac=new Student("abshgd",12+5);
    Student ad=new Student("newyut",52);

    stu.put("stu1",aa);
    stu.put("stu2",ab);
    stu.put("stu3",ac);
    stu.put("stu4",ad);
  //3.遍历
  //  通过键集合来获取
    Iterator iterator=stu.keySet().iterator();
    while (iterator.hasNext())
    {
    //  每一个键
      String key=(String) iterator.next();
    //  通过建得到值
      Student value=stu.get(key);
      System.out.println(key+"\t"+value);

    }
    System.out.println();

  }



}
